/**
 * @Author: Bobby
 * @Date: 2022-03-21 09:17:11
 * @LastEditTime: 2022-03-21 09:47:40
 * @LastEditors: Bobby
 * @Description:
 * @FilePath: \wms-v2\src\ve\eventTask\actions\form\runFormLogicConditon.js
 * @CIMC-V2
 */

//必须带done回调 执行完成调用 vm, action, done

export default function runFormLogicConditon({ vm, action, done, eventName }) {
  if (action.extension.formSelect.value.length > 0) {
    action.extension.formSelect.value.forEach((item) => {
      let _form = vm.vuiComponents[item]
      if (_form) {
        // 表单的逻辑条件运行成功则进行下一个动作
        if (_form.self.handlerLogicCondition && _form.self.handlerLogicCondition()) {
          done(null, {})
        } else {
          // 修改任务队列执行状态，防止下一次事件被拦截
          vm[`${eventName}IsRunning`] = false
        }
      } else {
        console.log('没找到form组件')
        done(null, {})
      }
    })
  } else {
    // 如果未选择表单组件 则直接运行下一个动作
    done(null, {})
  }
}
